package com.hspedu.reflection.question;

import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/3/23
 * @time 16:36
 */
public class ReflectionUtils {
    public static void main(String[] args) {

    }

    /**
     * 第一组方法
     */
    @Test
    public void api_01() throws ClassNotFoundException {
        Class personClass = Class.forName("com.hspedu.reflection.question.Person");
        System.out.println("personClass.getName() = " + personClass.getName());
        System.out.println("personClass.getSimpleName() = " + personClass.getSimpleName());
        Field[] fields = personClass.getFields();
        for (Field field : fields) {
            System.out.println(field);
        }
        Field[] declaredFields = personClass.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            System.out.println(declaredField);
        }
    }
}

class A{
    public String hobby;
}

class Person extends A{
    public String name;
    protected int age;
    String job;
    private double sal;

    public void m1() {

    }

    protected void m2() {
    }

    void m3() {
    }

    private void m4() {
    }
}